﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProductionPlanning" @search="()=>{getTableDataProductionPlanning();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Wo_FormItem" prop="Wo" :label="$t('message.autotrans._Model_ProductionPlanning_Wo')">
            <el-input v-model="searchDataProductionPlanning.Wo" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Sort_FormItem" prop="Sort" :label="$t('message.autotrans._Model_ProductionPlanning_Sort')">
            <el-input v-model="searchDataProductionPlanning.Sort" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineId_FormItem" prop="LineId" :label="$t('message.autotrans._Model_ProductionPlanning_LineId')">
            <el-input v-model="searchDataProductionPlanning.LineId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineCode_FormItem" prop="LineCode" :label="$t('message.autotrans._Model_ProductionPlanning_LineCode')">
            <el-input v-model="searchDataProductionPlanning.LineCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ShiftId_FormItem" prop="ShiftId" :label="$t('message.autotrans._Model_ProductionPlanning_ShiftId')">
            <el-input v-model="searchDataProductionPlanning.ShiftId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ShiftCode_FormItem" prop="ShiftCode" :label="$t('message.autotrans._Model_ProductionPlanning_ShiftCode')">
            <el-input v-model="searchDataProductionPlanning.ShiftCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_ProductionPlanning_ProductId')">
            <el-input v-model="searchDataProductionPlanning.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductCode_FormItem" prop="ProductCode" :label="$t('message.autotrans._Model_ProductionPlanning_ProductCode')">
            <el-input v-model="searchDataProductionPlanning.ProductCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductName_FormItem" prop="ProductName" :label="$t('message.autotrans._Model_ProductionPlanning_ProductName')">
            <el-input v-model="searchDataProductionPlanning.ProductName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanStartTime_FormItem" prop="PlanStartTime" :label="$t('message.autotrans._Model_ProductionPlanning_PlanStartTime')">
            <el-date-picker v-model="searchDataProductionPlanning.PlanStartTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanEndTime_FormItem" prop="PlanEndTime" :label="$t('message.autotrans._Model_ProductionPlanning_PlanEndTime')">
            <el-date-picker v-model="searchDataProductionPlanning.PlanEndTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanQty_FormItem" prop="PlanQty" :label="$t('message.autotrans._Model_ProductionPlanning_PlanQty')">
            <el-input v-model="searchDataProductionPlanning.PlanQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="PlanStatus_FormItem" prop="PlanStatus" :label="$t('message.autotrans._Model_ProductionPlanning_PlanStatus')">
            <el-select v-model="searchDataProductionPlanning.PlanStatus" clearable>
               <el-option key="Created" value="Created" :label="$t('message.autotrans._Enum_WoStatusEnum_Created')"></el-option>
               <el-option key="Scheduled" value="Scheduled" :label="$t('message.autotrans._Enum_WoStatusEnum_Scheduled')"></el-option>
               <el-option key="Issued" value="Issued" :label="$t('message.autotrans._Enum_WoStatusEnum_Issued')"></el-option>
               <el-option key="Executing" value="Executing" :label="$t('message.autotrans._Enum_WoStatusEnum_Executing')"></el-option>
               <el-option key="Completed" value="Completed" :label="$t('message.autotrans._Enum_WoStatusEnum_Completed')"></el-option>
               <el-option key="Paused" value="Paused" :label="$t('message.autotrans._Enum_WoStatusEnum_Paused')"></el-option>
               <el-option key="Freezed" value="Freezed" :label="$t('message.autotrans._Enum_WoStatusEnum_Freezed')"></el-option>
               <el-option key="Canceled" value="Canceled" :label="$t('message.autotrans._Enum_WoStatusEnum_Canceled')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProductionPlanning_CreateTime')">
            <el-date-picker v-model="searchDataProductionPlanning.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProductionPlanning_UpdateTime')">
            <el-date-picker v-model="searchDataProductionPlanning.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProductionPlanning_CreateBy')">
            <el-input v-model="searchDataProductionPlanning.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProductionPlanning_UpdateBy')">
            <el-input v-model="searchDataProductionPlanning.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/PlanningManagement/ProductionPlanning/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionPlanning/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionPlanning/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionPlanning/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/PlanningManagement/ProductionPlanning/ProductionPlanningExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProductionPlanning" v-bind="tableDataProductionPlanning">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="240">
        <template v-slot="scope">
					<WtmButton   :is-text="true" icon='fa fa-pencil-square' type='primary'
											 :disabled="(scope.row.ProductionPlanning_PlanStatus !== 'Created')"
											 :button-text="$t('message.autotrans.ToOrder')" @click="OnToOrderrowClick(scope.row)"  :confirm="$t('message.autotrans.confirm')" />
					<WtmButton   :disabled="(scope.row.ProductionPlanning_PlanStatus !== 'Created')" v-auth="'/api/PlanningManagement/ProductionPlanning/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/PlanningManagement/ProductionPlanning/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton  :disabled="(scope.row.ProductionPlanning_PlanStatus !== 'Created')" v-auth="'/api/PlanningManagement/ProductionPlanning/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PagePlanningManagementProductionPlanningIndex;true;Digitalmes.PlanningManagement.Controllers;ProductionPlanning">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { productionplanningApi } from '/@/api/planningmanagement/productionplanning';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProductionPlanning = reactive({
    
});

const searchDataProductionPlanning = ref({
        Wo: '',
        Sort: null,
        LineId: null,
        LineCode: '',
        ShiftId: null,
        ShiftCode: '',
        ProductId: null,
        ProductCode: '',
        ProductName: '',
        PlanStartTime: undefined,
        PlanEndTime: undefined,
        PlanQty: null,
        PlanStatus: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProductionPlanning = ref();
const tableDataProductionPlanning = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工单号'),key: 'ProductionPlanning_Wo',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page排序'),key: 'ProductionPlanning_Sort',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page产线'),key: 'ProductionPlanning_LineId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产线'),key: 'ProductionPlanning_LineCode',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page班次'),key: 'ProductionPlanning_ShiftId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page班次'),key: 'ProductionPlanning_ShiftCode',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page产品'),key: 'ProductionPlanning_ProductId',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'ProductionPlanning_ProductCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'ProductionPlanning_ProductName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page计划开始时间'),key: 'ProductionPlanning_PlanStartTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page计划结束时间'),key: 'ProductionPlanning_PlanEndTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page计划数量'),key: 'ProductionPlanning_PlanQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page计划状态'),key: 'ProductionPlanning_PlanStatus',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProductionPlanning_CreateTime',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProductionPlanning_UpdateTime',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProductionPlanning_CreateBy',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProductionPlanning_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProductionPlanning = () => {
    tableRefProductionPlanning.value.doSearch(productionplanningApi().search, searchDataProductionPlanning.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProductionPlanning)
};


const OnToOrderrowClick = (row: any) => {
	//other.openDialog(ci.proxy.$t('message.autotrans.ToOrder'), EditDialog, row, getTableDataProductionPlanning)
	productionplanningApi().toOrder(row.ID).then(() => { getTableDataProductionPlanning()})
};


const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProductionPlanning)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProductionPlanning)
};

// 删除
const onDelete = (row: any) => {
    productionplanningApi().delete([row.ID]).then(() => { getTableDataProductionPlanning()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProductionPlanning.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      productionplanningApi().delete(selectedids).then(() => { getTableDataProductionPlanning()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProductionPlanning.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProductionPlanning)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProductionPlanning)
};

const onExport = () => {
	const selected = tableRefProductionPlanning.value.getSelectedRows();
	if (selected.length > 0) {
		productionplanningApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		productionplanningApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataProductionPlanning();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

